<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRedTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('reds', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('member_id')->unsigned()->comment('用户id');
            $table->string('red_type',10)->comment('红包媒体类型(default=默认红包，image=图片红包，video=视频红包)');
            $table->integer('money')->unsigned()->comment('红包金额');
            $table->integer('pay')->unsigned()->comment('红包创建支付金额');
            $table->integer('charge')->unsigned()->comment('红包手续费');
            $table->tinyInteger('pay_type')->unsigned()->comment('发红包支付方式(0=未支付成功，1=余额支付，2=微信支付)');
            $table->tinyInteger('type')->unsigned()->comment('红包金额类型(1=普通红包，2=手气红包)');
            $table->tinyInteger('send_coupon')->unsigned()->default(0)->comment('红包内是否装入卡券（0=不设置卡券，1=设置卡券）');
            $table->integer('coupon')->unsigned()->default(0)->nullable()->comment('装入的卡券id');
            $table->tinyInteger('red_form')->unsigned()->default(0)->comment('是否开启红包表单');
            $table->integer('red_form_id')->unsigned()->default(0)->nullable()->comment('红包表单id');
            $table->integer('number')->unsigned()->comment('红包数量');
            $table->integer('numbered')->unsigned()->default(0)->comment('发红包数量');
            $table->char('title',10)->comment('红包标题');
            $table->string('media',50)->comment('素材id集合');
            $table->tinyInteger('question')->unsigned()->default(0)->comment('是否开启答题红包（0=不开启，1=选择题，2=问答题）');
            $table->text('answer')->comment('问答题答案（json字符串）');
            $table->tinyInteger('award')->unsigned()->comment('是否开启分享助力红包');
            $table->tinyInteger('time_type')->unsigned()->comment('红包时间限制1=永久有效，2=时间限制');
            $table->integer('start_time')->unsigned()->default(0)->comment('红包开始时间');
            $table->integer('end_time')->unsigned()->default(0)->comment('红包结束时间');
            $table->tinyInteger('area_type')->unsigned()->default(0)->comment('是否开启红包地区限制(0=不开启，1=省级限制，2=市级限制，3=区级限制)');
            $table->string('area',255)->nullable()->comment('限制地区');
            $table->integer('link')->unsigned()->nullable()->default(0)->comment('推广链接id(0=为开启，其他=推广链接id)');
            $table->tinyInteger('status')->default(1)->unsigned()->comment('红包状态（1=等待支付发红包，2=正常发布中，4=停止发红包，6=发红包未支付或者支付失败，8=发红包时支付异常，9=删除）');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('reds');
    }
}
